﻿using RTW.Core.Ioc;
using RTW.Core.Repository;
using RTW.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace RTW.Servers
{
    public class UserRoleserver : BaseServers<SysUserRole>, IAutoInject
    {
        private readonly IRepositoryAsync<SysUserRole> SysUserRoleRepository;
        public UserRoleserver()
        {
            SysUserRoleRepository = new DapperAsyncRepository<SysUserRole>();
        }

        public async Task<int> GetUserRoleCount()
        {
        
            return await SysUserRoleRepository.Count();
        }

        /// <summary>
        /// 根据用户ID获取数据
        /// </summary>
        /// <returns></returns>
        public async Task<List<SysUserRole>> GetUserRoleID(int? YHID)
        {
            return (await SysUserRoleRepository.SqlWithParams("select * from Sys_User_Role where YHID=:YHID",new { YHID = YHID })).ToList();
        }
    }
}
